[% setvar title Sane resolution to large function returns %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Sane resolution to large function returns</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Jerrad Pierce &lt;<a href='mailto:belg4mit@mit.edu'>belg4mit@mit.edu</a>&gt;
  Date: 17 Aug 2000
  Mailing List: <a href='mailto:perl6-internals@perl.org'>perl6-internals@perl.org</a>
  Number: 127
  Version: 1
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>Perl has traditionally returned from various functions long (&gt;3) lists
of values. This can be somewhat frustrating, especially if you require
one of the many datum returned. RFC 37 would have us break backward
compatability to solve this &quot;problem&quot;.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Functions like stat() and get*() return long lists of values.
The implementation is assumedly easy: just push some values
out of C structs into the Perl return stack.</p>
<p>This gives the end user a large list to deal with, which can be
unwieldy, especially when a single datum is desired. The typical
solution is to do something along the lines of <code>(stat($file))[8]</code>.
Not elegant, but it works.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>There has been a proposed new core function <code>want()</code>. this seems
to be generally regarded as a good thing. Fine. If it is implemented
we should use it. Offending functions (See RFC 37) should use
<code>want()</code> internally to determine what to return i.e; a list or a hash.</p>
<p>As for single datum access, <i>perhaps</i> <code>function-</code>[index]&gt; or
<code>function()-</code>{key}&gt; should be considered. This however, is not the
core of this proposal. Merely a possibility. Just as extending the
inelegant metaphor above to <code>{function()}-</code>{key}&gt; would become a
possibility.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>RFC 21: Replace <code>wantarray</code> with a generic <code>want</code> function</p>
<p>RFC 37: Positional Return Lists Considered Harmful</p>
</div>
